﻿using DevExpress.Mvvm;
using DevExpress.Mvvm.DataAnnotations;
using VGTimer.Models;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VGTimer.ViewModels
{
    [POCOViewModel]
    public class SettingViewModel
    {
        public SettingViewModel()
        {
            AllDevices = ConfigInfo.Instance.AllDevices;
        }

        public virtual ObservableCollection<Device> AllDevices { get; set; }

        public virtual ObservableCollection<string> DeviceType { get; set; } = new ObservableCollection<string>() {
            "PS5",
            "PS4",
            "PS3",
            "Xbox One",
            "Xbox Series X",
            "Xbox Series S",
            "Nintendo Switch",
            "PC",};

        public void ApplyConfig()
        {
            ConfigInfo.SaveConfig();
            Growl.Info("配置保存成功！");
        }

        public void AddDevice()
        {
            AllDevices.Add(new Device()
            {
                NickName = "新设备",
                Index = AllDevices.Count + 1,
                Detail = "设备的描述",
                DeviceType = "PS5",
            });
        }

        public void DeleteItem(Device device)
        {
            AllDevices.Remove(device);
            ConfigInfo.SaveConfig();
        }
    }
}
